package com.qianfeng.exam.mapper;

import com.qianfeng.exam.dto.BooksDto;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface BookMapper {
    @Insert("insert into books(authorid,bookdescription,bookname,bookpicurl,categoryid)value(#{authorId},#{bookDescription},#{bookName},#{bookPicUrl},#{categoryId})")
    @Options(useGeneratedKeys=true,keyProperty="bookid")//添加记录并返回数据库自增加的ID
    void addBook(BooksDto books);

    @Select("select * from books")
    List<BooksDto> findAllBook();
}
